<%@ page language="java" contentType="text/html;charset=UTF-8" %><%@ include file="../../inc/global.jsp" 
%>
<!doctype html>
<html>
<head>
<title>${adminGlobalConfig.name}</title>
<%@include file="../head.jsp" %>
<script type="text/javascript">
function Login() {
	var _this = this;
	this.init = function() {
		$('#loginbtn').click(function(){
			_this.dologin();
		});
	};
	this.dologin = function() {
		$(this).attr('disabled', 'disabled');
		var url='/a/ajax/dologin';
		var name = $('#name').val();
		var password = $('#password').val();
		$.ajax({
			url:url
			, type:'POST'
			, data:{nm:name,pwd:password}
			, success:function(data){
				var json = $.parseJSON(data);
				if(json.succeed) {
					var burl = $('#backURL').val();
					if(burl!=undefined || burl.length>0) {
						window.location = burl;
					} else {
						window.location = "/";
					}
				} else {
					alert('登录失败，用户名或密码错误！');
				}
				$('#loginbtn').removeAttr('disabled');
			}
			,error:function() {
				alert(MSG.ERR);
				$('#loginbtn').removeAttr('disabled');
			}
		});
	}
};
var login = new Login();
$(function(){
	login.init();
	$(document).keydown(function(){
		if(event.keyCode == KEY.ENTER) {
			login.dologin();
		}
	});
	$('#name').focus();
});
</script>
<style type="text/css">
.loginform {width:100%;}
.loginform table {width:500px; margin:30px auto;}
.loginform table tr, .loginform table td {height:40px;}
.loginform input[type=text]{width:300px; height:21px; line-height:21px; padding:3px;}
.loginform input[type=password]{width:300px; height:21px; line-height:21px; padding:3px;}
h3{font-size:16px; margin:31px auto 0px auto; text-align:center; padding:0px;}
</style>
</head>
<body>
<div class="wrapper">
<%@include file="../header.jsp" %>
<div class="body">
<div class="loginform">
<c:if test="${!empty m_m}">
<h3>${m_m.name} 已成功登录！</h3>
</c:if>
<table>
<tr>
<th>登录名称</th>
<td>
<input type="text" id="name" name="name" value="" />
</td>
</tr>
<tr>
<th>登录密码</th>
<td>
<input type="password" id="password" name="password" value="" />
</td>
</tr>
<tr>
<th></th>
<td>
<input type="button" id="loginbtn" name="loginbtn" value="确定登录" />
<input type="hidden" id="backURL" name="backURL" value="${backURL}" />
</td>
</tr>
</table>
</div>
<!--  -->
</div>
</div>
</body>
</html>